package com.orange.notificationsummary.utils;

import android.text.TextUtils;

public class MailUtils {
	public static String getGmailName(String gmail) {
		String gmailName = null;
		if (!TextUtils.isEmpty(gmail)) {
			String tempString = gmail.substring(1);
			int pos = tempString.indexOf('\"');
			gmailName = tempString.substring(0, pos);

		}
		return gmailName;
	}

	public static String getGmailAddress(String gmail) {
		String gmailName = null;
		if (null != gmail) {
			int beginPos = gmail.indexOf('<');
			int endPos = gmail.indexOf('>');
			gmailName = gmail.substring(beginPos + 1, endPos);
		}
		return gmailName;
	}

	public static String getGamil(String gmail) {
		String resultGmail = null;
		if (null != gmail) {
			resultGmail = getGmailName(gmail);
			if (TextUtils.isEmpty(resultGmail)) {
				resultGmail = getGmailAddress(gmail);
			}
		}
		return resultGmail;
	}

	public static boolean isNewGmail(String labelIds, String unreadLabel) {
		boolean isNewGmail = false;
		if (!TextUtils.isEmpty(labelIds) && labelIds.contains(unreadLabel)) {
			isNewGmail = true;
		}
		return isNewGmail;
	}
}
